<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<%@ include file="/common/common-css.jsp"%>
<style>
#jquery-table td {
	cursor: pointer !important
}

.load_bg {
	background: #000;
	opacity: 0.1;
	left: 0px;
	top: 0px;
	position: fixed;
	height: 100%;
	width: 100%;
	overflow: hidden;
	z-index: 10000;
}

.load_img {
	left: 50%;
	top: 180px;
	position: fixed;
	height: 50px;
	overflow: hidden;
	z-index: 20000;
}
</style>
</head>
<body class="no-skin">
	<div class="load_bg" style="display: none;"></div>
	<img src="http://img.xmiles.cn/commentloading.gif" class="load_img"
		style="display: none" />
	<div class="page-content">
		<div class="page-header"
			style="margin-bottom: 0px; padding-bottom: 10px;"></div>

		<form id="queryForm">
			<div class="page-content-area">
				<div class="row">
					<div class="col-sm-12">
						<div class="widget-box"
							style="border: 0px solid #ccc; border-top: none; border-bottom: none;">
							<div class="widget-header widget-header-blue widget-header-flat">
								<h4 class="widget-title">选择条件进行查询</h4>
								<div class="widget-toolbar">
									<a href="#" data-action="collapse"> <i
										class="ace-icon fa fa-chevron-up"></i>
									</a>
								</div>
							</div>
							<div class=" widget-body">
								<div class="widget-main">
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">平台:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" name="platform">
												<option value="">全部</option>
												<option value="0">通用</option>
												<option value="android">安卓</option>
												<option value="ios">ios</option>
											</select>
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-3 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">产品</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select id="prdid" name="prd_id" class="form-control"></select>
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-3 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">渠道</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select id="channel" name="channel"></select>
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">用户id:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" style="padding-left: 0px" name="userid"
												id="userid">
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">手机号:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" style="padding-left: 0px" name="mobnum"
												id="mobnum">
										</div>
									</div>
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">黑名单来源:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" name="comefrom">
												<option value="">不限</option>
												<option value="百度金融">百度金融</option>
												<option value="点金">点金</option>
											</select>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-12 center">
						<div class="clearfix form-actions">
							<button class="btn btn-purple  no-border" type="button"
								name="btn-query" onclick="query_any()" id="btn-query">
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
								查询
							</button>
							&nbsp;&nbsp;&nbsp;
							<button class="btn btn-grey  no-border" type="reset">
								<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i> 重置
							</button>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<a href="javascript:void(0)" class="btn btn-success btn-small"
							id="output" onclick="loadlist()">导出列表</a>
						<table id="jquery-table"
							class="table table-striped table-bordered table-hover">
						</table>
					</div>
				</div>
			</div>
		</form>
	</div>

	<%@ include file="/common/common-js.jsp"%>
	<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
	<script type="text/javascript"
		src="${ctx}/ace/js/jquery.dataTables.min.js"></script>

	<script type="text/javascript">
	
		function loadlist() {
			var form = document.forms["queryForm"];
			form.action = ctx + "/baidublack/exportData.action";
			form.submit();
		}
		
		var souceList = null;
		//【查询】按钮Click事件
		function query_any() {
			$(".load_bg").removeAttr("style");
			$(".load_img").removeAttr("style");
			if (jqTable != null) {
				jqTable.fnDraw();
			} else {
				loaddata();
			}
		}
		var jqTable = null;
		var loaddata = function() {
			jQuery(function($) {
				jqTable = $('#jquery-table').dataTable(
						{
							//数据列控制（包括对应返回JSON属性名称，对应表头列索引位置、数据转换封装等）
							"columnDefs" : [
							{
								"title" : '用户id',
								"name" : "userid",
								"data" : "userid",
								"targets" : [ 0 ],
								"bSortable" : false,
							}, 
							{
								"title" : '手机号',
								"name" : "mobnum",
								"data" : "mobnum",
								"targets" : [ 1],
								"bSortable" : false,
							}, 
							{
								"title" : '平台',
								"name" : "platform",
								"data" : "platform",
								"targets" : [ 2 ],
								"bSortable" : false,
							}, 
							{
								"title" : '激活产品',
								"name" : "pdname",
								"data" : "pdname",
								"targets" : [ 3 ],
								"bSortable" : false,
							},

							{
								"title" : "渠道",
								"name" : "channel_name",
								"data" : "channel_name",
								"targets" : [ 4 ],
								"bSortable" : false,
							}, 
							{
								"title" : "注册时间",
								"name" : "createtime",
								"data" : "createtime",
								"targets" : [ 5 ],
								"bSortable" : true,
							}, 
							{
								"title" : "验证时间 ",
								"name" : "checktime",
								"data" : "checktime",
								"targets" : [ 6 ],
								"bSortable" : true,
								"render" : function(value, type, row) { // 返回自定义内容
									if (value == null) {
										return "--";
									} else {
										return value;
									}
								}
							},

							{
								"title" : "验证来源",
								"name" : "comefrom",
								"data" : "comefrom",
								"targets" : [ 7 ],
								"bSortable" : false,
							},

							{
								"title" : "验证结果",
								"name" : "blacklevel",
								"data" : "blacklevel",
								"targets" : [ 8 ],
								"bSortable" : false,
								"render" : function(value, type, row) { // 返回自定义内容
								if(value!=null&&value!=""){
									if (value == 'A') {
										return "A级极黑用户";
									  }
									if(value=='B'){
										return "B级高危用户";
									  }
									if(value=='C'){
										return "C级值得关注用户";
									  }
									if(value=='D'){
										return "D级有黑名单风险"
									  }
								  }else {
									return "信用良好";
								}
							  } 
							} ,
							{
								"title" : "操作",
								"name" : "operation",
								"data" : "operation",
								 "class": "center",
								"targets" : [ 9 ],
								"bSortable" : false,
								 "render": function(value, type, row) {
									  var statusClass = "btn-success";
									  if(row.userid)
											return "<a class='btn btn-send " + statusClass + " btn-sm' href='javascript:void(0)' data_id=" + row.id + " data_userid=" + row.userid + " onclick='getDetail(this)'>查看详情</a>"	
								  }
							} 
								],
							"sAjaxSource" : ctx + "/baidublack/list.action",
							"fnServerData" : function(sSource, aoData,
									fnCallback) {//从服务器请求数据
								var data = $('#queryForm').serializeObject();
								data.aoData = JSON.stringify(aoData);
								//alert(sSource);
								$.ajax({
									"dataType" : 'json',
									"type" : "POST",
									"url" : sSource,
									"data" : data,
									"success" : function(resp) {
										$(".load_bg").attr("style",
												"display:none");
										$(".load_img").attr("style",
												"display:none");
										$("#hidden_pass").attr("style",
												"display:block");
										$('#jquery-table').removeClass(
												"dataTable");
										fnCallback(resp);
										initListPage();
									},
									"error" : function(XMLHttpRequest,
											textStatus, errorThrown) {
										$(".load_bg").attr("style",
												"display:none");
										$(".load_img").attr("style",
												"display:none");
										alert('请求服务器错误,请刷新重试！！'); //错误提示，包括服务器重启导致的session失效
									}
								});
							},
							"fnRowCallback" : function(nRow, aData,
									iDisplayIndex, iDisplayIndexFull) {
							},
							"bDestroy" : true,
							"bScrollInfinite" : true,
							"sScrollXInner" : "100%",
							"sScrollY" : "100%",//如果不设置，IE会有问题
							"aaSorting" : [ [ 0, "desc" ] ]
						//初始化加载，默认按第几列排序、排序方式（列从0开始计算）
						});
			});
		}

	/* 	function initDate() {
			var beforedate = GetDateStr(-5);
			var today = GetDateStr(0);
			if ($.isBlank($("#createStartTime").val())) {
				jQuery("#createStartTime").val(beforedate);
			}
			if ($.isBlank($("#createEndTime").val())) {
				jQuery("#createEndTime").val(today);
			}
		} */

		/* function GetDateStr(AddDayCount) {
			var dd = new Date();
			dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期
			var y = dd.getFullYear();
			var m = dd.getMonth() + 1;//获取当前月份的日期
			var d = dd.getDate();
			return y + "-" + m + "-" + d;
		} */

		//时间控件
		/* jQuery(function($) {
			$(".date-picker").datepicker({
				autoclose : true
			}).next().on(ace.click_event, function() {
				$(this).prev().focus();
			});
		}); */
		
		function getDetail($this){
			var id = $this.getAttribute("data_id");
			var userid = $this.getAttribute("data_userid");
			openDialogWithRand("/baidublack/getDetail.action?data_id="+ id + "&data_userid="+userid+"",800,800,"",function (data){});
		}

		$(document).ready(function() {
			query_any();
			//initDate();
			loadChannel();
			loadProduct();
			$("#channel").combobox();
		});
	</script>
</body>
</html>